home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / Classface.mod < prev    next >
Text File  |  1995-06-29  |  5KB  |  163 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: Classface.mod $
  4.   Description: BOOPSI support routines.
  5.      Requires: ClassFace.obj must be explicitly linked with the program.
  6.  
  7.    Created by: fjc (Frank Copeland)
  8.     $Revision: 3.3 $
  9.       $Author: fjc $
  10.         $Date: 1995/06/04 23:13:14 $
  11.  
  12.   Copyright © 1994-1995, Frank Copeland.
  13.   This file is part of the Oberon-A Library.
  14.   See Oberon-A.doc for conditions of use and distribution.
  15.  
  16. *************************************************************************)
  17.  
  18. <* STANDARD- *> <*$ StackChk- NilChk- *>
  19.  
  20. MODULE [4] Classface ["Classface.o"];
  21.  
  22. IMPORT SYS := SYSTEM, e := Exec, u := Utility, i := Intuition;
  23.  
  24. (*
  25. ** These procedures *should* be in Intuition.mod.
  26. *)
  27.  
  28. (*------------------------------------*)
  29. PROCEDURE [0] InstData* (cl : i.IClassPtr; o : i.ObjectPtr) : e.APTR;
  30. BEGIN
  31.   RETURN SYS.VAL (e.APTR, (SYS.VAL(LONGINT,o) + LONG(cl.instOffset)));
  32. END InstData;
  33.  
  34. (*------------------------------------*)
  35. PROCEDURE [0] SizeOfInstance* (cl : i.IClassPtr) : LONGINT;
  36. BEGIN
  37.   RETURN cl.instOffset + cl.instSize + SIZE(i.Object);
  38. END SizeOfInstance;
  39.  
  40. (*------------------------------------*)
  41. PROCEDURE [0] OClass* (o : i.ObjectPtr) : i.IClassPtr;
  42. BEGIN
  43.   o := SYS.VAL (i.ObjectPtr, SYS.VAL (LONGINT, o) - SIZE (i.Object));
  44.   RETURN o.class
  45. END OClass;
  46.  
  47. (*
  48. ** The following declarations are interfaces to procedures in
  49. ** ClassFace.obj, created by assembling ClassFace.asm. ClassFace.obj
  50. ** must be explicitly linked with the program in order to call these
  51. ** procedures. See the "Foreign Code" section in OC.doc.
  52. **
  53. ** These procedures are replacements for those in Commodore's
  54. ** amiga.lib and small.lib.
  55. **
  56. ** Thanks to Albert Weinert for providing the assembly source code.
  57. *)
  58.  
  59. (*
  60. ** DoMethod( o, method_id, param1, param2, ... )
  61. ** Invoke upon an object the method function defined by an object's class.
  62. ** This function is the only one that you should use unless you are
  63. ** implementing a class.
  64. *)
  65.  
  66. PROCEDURE DoMethodA * ["_a_DoMethodA"]
  67.   ( obj    [10] : i.ObjectPtr;
  68.     VAR msg [9] : i.MsgBase )
  69.   : e.APTR;
  70.  
  71. PROCEDURE DomethodA * ["_a_DoMethodA"]
  72.   ( obj    [10] : i.ObjectPtr;
  73.     VAR msg [9] : i.MsgBase );
  74.  
  75. PROCEDURE DoMethod * ["_a_DoMethodA"]
  76.   ( obj [10]  : i.ObjectPtr;
  77.     msg  [9]..: SYS.LONGWORD )
  78.   : e.APTR;
  79.  
  80. PROCEDURE Domethod * ["_a_DoMethodA"]
  81.   ( obj [10]  : i.ObjectPtr;
  82.     msg  [9]..: SYS.LONGWORD );
  83.  
  84. (*
  85. ** DoSuperMethod( cl, o, method_id, param1, param2, ... )
  86. ** Invoke upon an object the method defined for the superclass
  87. ** of the class specified.  In a class implementation, you
  88. ** are passed a pointer to the class you are implementing, which
  89. ** you pass to this function to send a message to the object
  90. ** considered as a member of your superclass.
  91. *)
  92.  
  93. PROCEDURE DoSuperMethodA * ["_a_DoSuperMethodA"]
  94.   ( cl      [8] : i.IClassPtr;
  95.     obj    [10] : i.ObjectPtr;
  96.     VAR msg [9] : i.MsgBase )
  97.   : e.APTR;
  98.  
  99. PROCEDURE DoSupermethodA * ["_a_DoSuperMethodA"]
  100.   ( cl      [8] : i.IClassPtr;
  101.     obj    [10] : i.ObjectPtr;
  102.     VAR msg [9] : i.MsgBase );
  103.  
  104. PROCEDURE DoSuperMethod * ["_a_DoSuperMethodA"]
  105.   ( cl   [8]  : i.IClassPtr;
  106.     obj [10]  : i.ObjectPtr;
  107.     msg  [9]..: SYS.LONGWORD )
  108.   : e.APTR;
  109.  
  110. PROCEDURE DoSupermethod * ["_a_DoSuperMethodA"]
  111.   ( cl   [8]  : i.IClassPtr;
  112.     obj [10]  : i.ObjectPtr;
  113.     msg  [9]..: SYS.LONGWORD );
  114.  
  115. (*
  116. ** CoerceMethod( cl, o, method_id, param1, param2, ... );
  117. ** Invoke upon the given object a method function for whatever
  118. ** specified class.  This is sort of the primitive basis behind
  119. ** DoMethod and DoSuperMethod.
  120. *)
  121.  
  122. PROCEDURE CoerceMethodA * ["_a_CoerceMethodA"]
  123.   ( cl      [8] : i.IClassPtr;
  124.     obj    [10] : i.ObjectPtr;
  125.     VAR msg [9] : i.MsgBase )
  126.   : e.APTR;
  127.  
  128. PROCEDURE CoercemethodA * ["_a_CoerceMethodA"]
  129.   ( cl      [8] : i.IClassPtr;
  130.     obj    [10] : i.ObjectPtr;
  131.     VAR msg [9] : i.MsgBase );
  132.  
  133. PROCEDURE CoerceMethod * ["_a_CoerceMethodA"]
  134.   ( cl   [8]  : i.IClassPtr;
  135.     obj [10]  : i.ObjectPtr;
  136.     msg  [9]..: SYS.LONGWORD )
  137.   : e.APTR;
  138.  
  139. PROCEDURE Coercemethod * ["_a_CoerceMethodA"]
  140.   ( cl   [8]  : i.IClassPtr;
  141.     obj [10]  : i.ObjectPtr;
  142.     msg  [9]..: SYS.LONGWORD );
  143.  
  144. (*
  145. ** SetSuperAttrs( cl, o, tag1, data1, ..., TAG_END );
  146. ** A useful varargs conversion to the proper OM_SET method.
  147. *)
  148.  
  149. PROCEDURE SetSuperAttrsA * ["_a_SetSuperAttrs"]
  150.   ( cl   [8] : i.IClassPtr;
  151.     obj [10] : i.ObjectPtr;
  152.     tags [9] : ARRAY OF u.TagItem )
  153.   : e.APTR;
  154.  
  155. PROCEDURE SetSuperAttrs * ["_a_SetSuperAttrs"]
  156.   ( cl   [8]  : i.IClassPtr;
  157.     obj [10]  : i.ObjectPtr;
  158.     tags [9]..: u.Tag )
  159.   : e.APTR;
  160.  
  161. END Classface.
  162.  
  163.